package com.hina.rec.endpoint;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hina.rec.application.service.SettlePaymentService;
import com.hina.rec.common.model.Result;
import com.hina.rec.endpoint.req.IdReq;
import com.hina.rec.endpoint.req.SettlePaymentSaveReq;
import com.hina.rec.endpoint.req.SettlePaymentSearchReq;
import com.hina.rec.endpoint.req.SettlePaymentUpdateReq;
import com.hina.rec.endpoint.res.SettlePaymentRes;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 结算单回款接口
 *
 * @author dequal
 * @since 2025-05-23
 */
@Tag(name = "结算单回款接口", description = "结算单回款接口")
@RestController
@RequestMapping("/settle_payment")
@RequiredArgsConstructor
public class SettlePaymentEndpoint {

    private final SettlePaymentService settlePaymentService;

    /**
     * 分页查询结算单回款
     *
     * @param req 查询请求
     * @return 分页结果
     */
    @PostMapping("/page")
    @Operation(summary = "分页查询结算单回款", description = "分页查询结算单回款")
    public Result<Page<SettlePaymentRes>> page(@RequestBody SettlePaymentSearchReq req) {
        Page<SettlePaymentRes> page = settlePaymentService.page(req);
        return Result.success(page);
    }

    /**
     * 创建结算单回款
     *
     * @param req 创建请求
     * @return 创建结果
     */
    @PostMapping("/save")
    @Operation(summary = "创建结算单回款", description = "创建结算单回款")
    public Result<Void> save(@RequestBody SettlePaymentSaveReq req) {
        settlePaymentService.save(req);
        return Result.success();
    }

    /**
     * 更新结算单回款
     *
     * @param req 更新请求
     * @return 更新结果
     */
    @PostMapping("/update")
    @Operation(summary = "更新结算单回款", description = "更新结算单回款")
    public Result<Void> update(@RequestBody SettlePaymentUpdateReq req) {
        settlePaymentService.update(req);
        return Result.success();
    }

    /**
     * 删除结算单回款
     *
     * @param req 删除请求
     * @return 删除结果
     */
    @PostMapping("/delete")
    @Operation(summary = "删除结算单回款", description = "删除结算单回款")
    public Result<Void> delete(@RequestBody IdReq req) {
        settlePaymentService.delete(req.getId());
        return Result.success();
    }
} 